package com.jsgt.greekfire.dao.dao

import androidx.lifecycle.LiveData
import androidx.room.*
import com.jsgt.greekfire.dao.model.IdentityBean

@Dao
interface IdentityBeanDao {
    @Query("select * from identity")
    fun get(): LiveData<List<IdentityBean>>

    @Query("select * from identity where id = :id")
    fun get(id:Int): LiveData<IdentityBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun add(identityBean: IdentityBean)

    @Delete
    fun delete(identityBean: IdentityBean?)

    @Query("delete from identity where id = :id")
    fun delete(id:Int)

    @Query("delete from identity")
    fun clear()

    @Update
    fun update(identityBean: IdentityBean)

    @Update(entity = IdentityBean::class)
    fun updateBackup(vararg backup: IdentityBean.Backup)

    @Update(entity = IdentityBean::class)
    fun updateName(vararg name: IdentityBean.Name)
}